package testcase;

import information.Line;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

/**
 * @author Louis Luk(52591063), Peter Au Yeung(52582030), Sam Cheung(52603693)
 * @version for Line.java v2.1.2 refactor by Rigsby Chi(52584035)
 * @since 09-04-2013
 */

public class LineTest {
	private Line temp1;
	private Line temp2;

	@Before
	public void setUp() throws Exception {
		// Creation of 2 lines for testing purpose.
		temp1 = new Line(1220, 50, 5, 20, 1);
		temp2 = new Line(830, 90, 2, 10, 2);
	}

	@Test
	// Test for the output for the function "getStartTime()" for temp1
	public void testGetStartTime_temp1() {
		assertEquals(temp1.getStartTime(), 1220);
	}

	@Test
	// Test for the output for the function "getStartTime()" for temp2
	public void testGetStartTime_temp2() {
		assertEquals(temp2.getStartTime(), 830);
	}

	@Test
	public void testgetLineInfo() {
		int expectedResult[] = { 1220, 50, 5, 20, 1 };
		assertArrayEquals(expectedResult, temp1.getLineInfo());
	}

	@Test
	// Test for the output for the function "getFreq()" for temp1
	public void testGetFreq_temp1() {
		assertEquals(temp1.getFreq(), 50);
	}

	@Test
	// Test for the output for the function "getFreq()" for temp2
	public void testGetFreq_temp2() {
		assertEquals(temp2.getFreq(), 90);
	}

	@Test
	// Test for the output for the function "getRuns()" for temp1
	public void testGetRuns_temp1() {
		assertEquals(temp1.getRuns(), 5);
	}

	@Test
	// Test for the output for the function "getRuns()" for temp2
	public void testGetRuns_temp2() {
		assertEquals(temp2.getRuns(), 2);
	}

	@Test
	// Test for the output for the function "getDuration()" for temp1
	public void testGetDuration_temp1() {
		assertEquals(temp1.getDuration(), 20);
	}

	@Test
	// Test for the output for the function "getDuration()" for temp2
	public void testGetDuration_temp2() {
		assertEquals(temp2.getDuration(), 10);
	}

	@Test
	// Test for the output for the function "getSizeOfShip()" for temp1
	public void testGetSizeOfShip_temp1() {
		assertEquals(temp1.getSizeOfShip(), 1);
	}

	@Test
	// Test for the output for the function "getSizeOfShip()" for temp2
	public void testGetSizeOfShip_temp2() {
		assertEquals(temp2.getSizeOfShip(), 2);
	}

	@Test
	public void testIsEqual_equal() {
		Line line1 = new Line(1, 2, 3, 4, 5);
		Line line2 = new Line(1, 2, 3, 4, 5);
		assertEquals(true, line1.equals(line2));
	}

	@Test
	public void testIsEqual_unequal_1() {
		Line line1 = new Line(1, 2, 3, 4, 5);
		Line line2 = new Line(2, 2, 3, 4, 5);
		assertEquals(false, line1.equals(line2));
	}

	@Test
	public void testIsEqual_unequal_2() {
		Line line1 = new Line(1, 2, 3, 4, 5);
		Line line2 = new Line(1, 3, 3, 4, 5);
		assertEquals(false, line1.equals(line2));
	}

	@Test
	public void testIsEqual_unequal_3() {
		Line line1 = new Line(1, 2, 3, 4, 5);
		Line line2 = new Line(1, 2, 4, 4, 5);
		assertEquals(false, line1.equals(line2));
	}

	@Test
	public void testIsEqual_unequal_4() {
		Line line1 = new Line(1, 2, 3, 4, 5);
		Line line2 = new Line(1, 2, 3, 5, 5);
		assertEquals(false, line1.equals(line2));
	}

	@Test
	public void testIsEqual_unequal_5() {
		Line line1 = new Line(1, 2, 3, 4, 5);
		Line line2 = new Line(1, 2, 3, 4, 6);
		assertEquals(false, line1.equals(line2));
	}
}
